<?php

namespace longhu\services\easywechat\listener;

use longhu\services\easywechat\listener\store\MessageInterface;
use think\Exception;

class MessageFacade
{
    public function make(string $optionName): MessageInterface
    {
        $optionName = ucfirst($optionName).'Message';
        $className = __NAMESPACE__.'\\store\\'.$optionName;

        $class = new $className();

        if (! $class instanceof MessageInterface) {
            throw new Exception('message must be implement [MessageInterface]');
        }

        return $class;
    }
}